package netty.study.fourth.server;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.concurrent.TimeUnit;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName MyServerChannelIniltializer.java
 * @Description TODO
 * @createTime 2020年04月17日 16:57:00
 */
public class MyServerChannelIniltializer extends ChannelInitializer {
	@Override
	protected void initChannel(Channel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();
		//空闲状态处理，读，写，或者靓仔在任何动作在一段时间内没有发生就会触发IdleStateEvent事件
		pipeline.addLast(new IdleStateHandler(10,10,20, TimeUnit.SECONDS));
		pipeline.addLast(new MyServerHandler());
	}
}
